package com.tjise.servicebase.exceptionhandler;


import com.tjise.commonutils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: tjise_parent
 * @description: 统一异常处理类
 * @author: 郑朝文
 * @create: 2021-06-22 10:50
 **/
// 添加异常处理的注解
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    /**
     * 自定义的异常
     *
     * @param e
     * @return
     */
    @ExceptionHandler(TjiseException.class)
    @ResponseBody
    public R TjiseExceptionError(TjiseException e) {
        log.error(e.getMsg());
        return R.error().message(e.getMsg()).code(e.getCode());


    }
}


